<template>
  <div class="layer">
    <div class="header">
      <div class="left">
        <!-- <img src="@img/return-ico.png" alt=""> -->
      </div>
      <h3 class="title">标题</h3>
      <div class="right">
        <!-- <div class="r-notice">
				<img src="@img/notice-ico.png" alt="">
				<span>公告</span>
			</div> -->
      </div>
    </div>
    <div class="login-layer">
      <div class="login-text">
        <h3>手机快捷登录</h3>
        <p>未注册过的手机号将自动创建账号</p>
      </div>
      <div class="login-con">
        <div class="login-phone">
          <input
            type="text"
            placeholder="请输入手机号"
            v-model="formData.mobile"
          />
        </div>
        <div class="login-code">
          <input
            type="text"
            placeholder="请输入验证码"
            v-model="formData.ver_code"
          />
          <span v-show="show" @click="getCode">获取验证码</span>
          <span v-show="!show" class="count">{{ count }} s</span>
        </div>
        <a @click="loginBtn()" class="login-btn" href="javascript:;">登录</a>
      </div>
    </div>
    <!-- loading -->
    <div class="loading-layer" v-if="loading"><van-loading type="spinner" color="#fff" /></div>
  </div>
</template>

<script>
import { sendCode } from "@A/services/apiGather";
import publicData from "@A/mixins/publicData";
export default {
  name: "login-index",
  mixins: [publicData],
  components: {},
  data() {
    return {
      show: true,
      count: "",
      timer: null,
      formData: {
        mobile: "", // 手机号
        ver_code: "", // 验证码
        type: "mobile", // 类型
        password: "", // 密码
      },
    };
  },
  mounted() {},
  methods: {
    // 登录
    loginBtn() {
      this.loading = true;
      // localStorage.setItem("userInfo", JSON.stringify(res.data)); // 存储
      this.$router.push({
        path: "/user-info",
        query: {
          id: "19961022",
        }
      });
    },
    // 获取验证码
    getCode() {
      const TIME_COUNT = 60;
      if (!this.timer) {
        this.count = TIME_COUNT;
        this.show = false;
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= TIME_COUNT) {
            this.count--;
          } else {
            this.show = true;
            clearInterval(this.timer);
            this.timer = null;
          }
        }, 1000);
      }
    },
  },
  watch: {},
};
</script>
<style lang="scss" scoped>
.layer {
  width: 100%;
  min-height: 100%;
  background: #fff;
  padding-top: 0.44rem;
  box-sizing: border-box;

  .login-layer {
    width: 100%;
    padding: 0.15rem;
    box-sizing: border-box;
    .login-text {
      width: 100%;
      padding-top: 0.08rem;
      box-sizing: border-box;
      h3 {
        color: #333333;
        font-size: 0.16rem;
        line-height: 0.22rem;
      }
      p {
        color: #d2d2d2;
        font-size: 0.12rem;
        line-height: 0.16rem;
        padding-top: 0.06rem;
        box-sizing: border-box;
      }
    }
    .login-con {
      width: 100%;
      padding-top: 0.2rem;
      box-sizing: border-box;
      input {
        font-size: 0.14rem;
        line-height: 0.36rem;
        width: 100%;
        height: 0.36rem;
        border: none;
      }
      .login-phone {
        width: 100%;
        border-bottom: 1px solid #f5f5f5;
      }
      .login-code {
        width: 100%;
        display: flex;
        align-items: center;
        border-bottom: 1px solid #f5f5f5;
        margin-top: 0.14rem;
        input {
        }
        span {
          color: #1c88c8;
          font-size: 0.14rem;
          line-height: 0.36rem;
          flex-shrink: 0;
        }
      }
      .login-btn {
        display: block;
        color: #fff;
        font-size: 0.17rem;
        line-height: 0.35rem;
        text-align: center;
        width: 100%;
        height: 0.35rem;
        background: #1c88c8;
        border-radius: 0.2rem;
        margin-top: 0.34rem;
      }
    }
  }
}
</style>